<?php /* @var $this ProductController */ ?>
<?php if (Yii::app()->user->hasFlash('success')): ?>
    <div class="alert alert-success">  
        <a class="close" data-dismiss="alert">×</a>  
        <?php echo Yii::app()->user->getFlash('success') ?>
    </div>  
<?php endif ?>
<?php if (Yii::app()->user->hasFlash('error')): ?>
    <div class="alert alert-error">  
        <a class="close" data-dismiss="alert">×</a>  
        <?php echo Yii::app()->user->getFlash('error') ?>
    </div>  
<?php endif ?>
<?php $form = $this->beginWidget('CActiveForm'); ?>
<?php /* @var $form CActiveForm */ ?>
<div class="row">
    <div class="span12">
        <fieldset>  
            <legend>Mặt hàng</legend>  
            <div class='clearfix'>
                <label for="name">Sản phẩm</label>
                <div class='input'>
                    <?php echo $form->dropDownList($model, 'product_id', CHtml::listData(Product::model()->findAll(array('order' => 'product_id ASC')), 'product_id', 'title'), array('empty' => '- Chọn một sản phẩm -')) ?>
                    <?php echo $form->error($model, 'product_id'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Nhà cung cấp</label>
                <div class='input'>
                    <?php echo $form->dropDownList($model, 'supplier_id', CHtml::listData(Supplier::model()->findAll(array('order' => 'supplier_id ASC')), 'supplier_id', 'name'), array('empty' => '- Chọn một nhà cung cấp -')) ?>
                    <?php echo $form->error($model, 'supplier_id'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Tên mặt hàng</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'title', array('size' => 80, 'maxlength' => 45)); ?>
                    <?php echo $form->error($model, 'title'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Mã sản phẩm</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'code', array('maxlength' => 32)); ?>
                    <?php echo $form->error($model, 'code'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Giá</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'price', array('size' => 80, 'maxlength' => 45)); ?>
                    <?php echo $form->error($model, 'price'); ?>
                </div>
            </div>

            <div class='clearfix'>
                <label for="address">Số lượng</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'quantity', array(
                            'disabled' => true
                        ));
                    ?>
                    <?php if(!$model->isNewRecord): ?>
                    <?php echo CHtml::link('Nhập hàng', $this->createUrl('import',array('id' => $model->item_id)),array(
                        'style' => 'padding-bottom: 4px;'
                    ))?>
                    |
                    <?php echo CHtml::link('Xem lịch sử các lần nhập', $this->createUrl('history',array('id' => $model->item_id)),array(
                        'style' => 'padding-bottom: 4px;'
                    ))?>
                    <?php endif ?>
                </div>
            </div>
            
            <div class='clearfix'>
                <label for="address">Trình trạng kho</label>
                <div class='input'>
                    <?php echo $form->dropDownList($model, 'is_onstock', array(
                            '0' => 'Hết hàng',
                            '1' => 'Còn hàng'
                        )); ?>
                    <?php echo $form->error($model, 'quantity'); ?>
                </div>
            </div>
            
            <div class='clearfix'>
                <label for="address">Kích cỡ/Size</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'size', array('size' => 80, 'maxlength' => 45)); ?>
                    <?php echo $form->error($model, 'size'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Màu sắc</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'color', array('size' => 80, 'maxlength' => 45)); ?>
                    <?php echo $form->error($model, 'color'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Chất liệu</label>
                <div class='input'>
                    <?php echo $form->textField($model, 'material', array('size' => 80, 'maxlength' => 45)); ?>
                    <?php echo $form->error($model, 'material'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <label for="address">Mô tả</label>
                <div class='input'>
                    <?php echo CHtml::activeTextArea($model, 'description', array('rows' => 5, 'cols' => 100, 'class' => 'span5')); ?>
                    <?php echo $form->error($model, 'description'); ?>
                </div>
            </div>
            <div class='clearfix'>
                <div class='input'>
                    <?php echo CHtml::submitButton($model->isNewRecord ? 'Nhập mặt hàng mới' : 'Lưu lại thay đổi', array('class' => 'btn btn-primary')); ?>
                    <?php echo CHtml::button('Quay về trang mặt hàng', array('class' => 'btn', 'onclick' => 'javascript:location.href = \'' . $this->createUrl('list') . '\'')) ?>
                </div>
            </div>
        </fieldset> 
    </div>
</div>
<?php $this->endWidget(); ?>